package com.pirestupppai.imagetool.filtertool;

import android.content.Context;
import android.graphics.Bitmap;

import com.pirestupppai.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/5/12 0012.
 */

public class FilterManager {
    private static List<FilterItem> filterThumbs = new ArrayList<FilterItem>(10);
    private static List<FilterItem> processedThumbs = new ArrayList<FilterItem>(10);

    private FilterManager() {
    }

    public static void addThumb(FilterItem FilterItem) {
        filterThumbs.add(FilterItem);
    }

    public static List<FilterItem> processThumbs(Context context) {
        for (FilterItem thumb : filterThumbs) {
            // scaling down the image
            float size = context.getResources().getDimension(R.dimen.filter_preview_size);
            thumb.image = Bitmap.createScaledBitmap(thumb.image, (int) size, (int) size, false);
            thumb.image = thumb.filter.processFilter(thumb.image);
            //cropping circle
//            thumb.image = GeneralUtils.generateCircularBitmap(thumb.image);
            processedThumbs.add(thumb);
        }
        return processedThumbs;
    }

    public static void clearThumbs() {
        filterThumbs = new ArrayList<>();
        processedThumbs = new ArrayList<>();
    }
}
